import { Component, TemplateRef,OnInit, ViewChild, ViewContainerRef, AfterViewInit, ElementRef } from '@angular/core';

@Component({
  selector: 'app-viewchild',
  templateUrl: './viewchild.component.html',
  styleUrls: ['./viewchild.component.css']
})
export class ViewchildComponent implements OnInit {

  @ViewChild('tpl') tpl:TemplateRef<any>
  @ViewChild('tpl',{read:ViewContainerRef}) tplRef:ViewContainerRef
  constructor() { }

  ngOnInit() {
  }

  ngAfterViewInit(){
      this.tplRef.createEmbeddedView(this.tpl);
      setTimeout(()=> {
          this.tplRef.clear()
      }, 2000);
  }

}
